package com.ocom.payconfig.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ocom.common.entity.payconfig.EntitySchoolWifiInfo;
import com.ocom.common.vo.payconfig.schoolwifiinfo.SchoolWifiInfoVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface IDaoSchoolWifiInfo extends BaseMapper<EntitySchoolWifiInfo> {

    @Select({"<script>",
            "SELECT p.com_id, p.dept_id, d.dept_name, p.p_id, p.p_code, p.p_name, p.p_sex, ",
            "s.login_name, s.user_name, s.password, s.remark, s.status, s.update_user, s.update_time, ",
            "s.check_user, s.check_time ",
            "FROM personnel_info p ",
            "LEFT JOIN school_wifi_info s ON p.com_id = s.com_id AND p.p_id = s.p_id ",
            "LEFT JOIN dept_info d ON p.com_id = d.com_id AND p.dept_id = d.dept_id ",
            "WHERE p.com_id = #{schoolWifiInfoVo.comId} AND p.status = 0 ",
            "<if test='schoolWifiInfoVo.pCode != null'>AND p.p_code = #{schoolWifiInfoVo.pCode}</if> ",
            "<if test='schoolWifiInfoVo.pName != null'>AND p.p_name LIKE concat('%', #{schoolWifiInfoVo.pName}, '%')</if> ",
            "<if test='schoolWifiInfoVo.pId != null'>AND p.p_id = #{schoolWifiInfoVo.pId}</if> ",
            "<if test='schoolWifiInfoVo.deptId != null'>AND p.dept_id = #{schoolWifiInfoVo.deptId}</if> ",
            "<if test='schoolWifiInfoVo.loginName != null'>AND s.login_name LIKE concat('%', #{schoolWifiInfoVo.loginName}, '%')</if> ",
            "<if test='schoolWifiInfoVo.status != null'>AND s.status = #{schoolWifiInfoVo.status}</if> ",
            "ORDER BY s.update_time DESC",
            "</script>"})
    List<SchoolWifiInfoVo> getSchoolWifiList( @Param("schoolWifiInfoVo") SchoolWifiInfoVo schoolWifiInfoVo);

}
